home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 July
/
CMCD0704.ISO
/
Software
/
Shareware
/
Utilitare
/
Girder
/
girder331c.exe
/
{app}
/
help
/
girder.php
next >
Wrap
PHP Script
|
2002-10-22
|
3KB
|
112 lines
<?php
// need this on XS-HTTPD.
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
function sendMsg($args) {
$fp = fsockopen($args["host"],$args["port"], &$errno, &$errstr);
if (!$fp) { //Something didn't work....
echo "ERROR: $errno - $errstr\n";
return FALSE;
} else {
// First wake up the server, for security reasons it does not
// respond by it self it needs this string, why this odd word ?
// well if someone is scanning ports "connect" would be very obvious
// this one you'd never guess :-)
fputs($fp, "quintessence\n\r");
// The server now returns a cookie, the protocol works like the
// APOP protocol. The server gives you a cookie you add :<password>
// calculate the md5 digest out of this and send it back
// if the digests match you are in.
// We do this so that noone can listen in on our password exchange
// much safer then plain text.
$cookie = fgets($fp, 400);
// Trim all enters and whitespaces off
$cookie = trim($cookie);
// Combine the token <cookie>:$args[pword]
$token = $cookie . ":" . $args["password"];
// Calculate the digest
$digest = md5($token);
// add the enters
$digest = $digest . "\n";
// Send it to the server
fputs($fp, $digest );
// Get the answer
$res = fgets($fp, 400);
// If the password was correct and you are allowed to connect
// to the server, you'll get "accept"
if ( trim($res) != "accept" )
{
fclose($fp);
return FALSE;
}
if ( $args["payload"] <> "" )
{
fputs($fp, "payload ".$args["payload"]."\n");
}
// now just pipe those commands to the server
fputs($fp, $args["command"]."\n");
// tell the server that we are done nicely.
fputs($fp, "close\n");
fclose($fp);
return TRUE;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Page title</title>
</head>
<body>
<?php
if ( $HTTP_POST_VARS['send'] <> "" )
{
if ( sendMsg($HTTP_POST_VARS) == TRUE )
{
echo "command sent succesfully<br>";
}
else
{
echo "Connection failed. (bad password/connection blocked)<br>" ;
}
}
?>
<form action="msggirder.php" method="post">
<table>
<tr><td>Hostname</td><td><input type=text name="host" value="<?php echo $HTTP_POST_VARS["host"]; ?>"></td></tr>
<tr><td>Port</td><td><input type=text name="port" value="<?php echo $HTTP_POST_VARS["port"]; ?>"></td></tr>
<tr><td>Password</td><td><input type=password name="password" value="<?php echo $HTTP_POST_VARS["password"]; ?>"></td></tr>
<tr><td>Eventstring</td><td><input type=text name="command" value="<?php echo $HTTP_POST_VARS["command"]; ?>"></td></tr>
<tr><td>Payload</td><td><input type=text name="payload" value="<?php echo $HTTP_POST_VARS["payload"]; ?>"></td></tr>
<tr><td colspan=2><input type=submit name="send" value="go!"></td></tr>
</table>
<form>
</body>
</html>